Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize file write performance #795

Merged
merged 29 commits into from
Apr 29, 2019
Merged

Conversation

CoffeeLatte007
Copy link
Contributor

@CoffeeLatte007 CoffeeLatte007 commented Apr 15, 2019

Ⅰ. Describe what this PR did

  1. optimize file write performance and optimize saveHistory
  2. By the way,optimize closes gracefully.
  3. add sync write mode,it is suitable for data consistency scenarios.

mac: 2.2 GHz Intel Core i7. 4 core .
per_thread_write_file = per_thread_trx_num * 9

  1. new vs old
    ===========new file write aync mode====================
    thread nums:1, per_thread_trx_num:65535 ,cost2600
    thread nums:4, per_thread_trx_num:65535 ,cost13329
    thread nums:8, per_thread_trx_num:65535 ,cost27613
    thread nums:16, per_thread_trx_num:65535 ,cost57764
    ===========old file write aync mode====================
    thread nums:1, per_thread_trx_num:65535 ,cost17816
    thread nums:4, per_thread_trx_num:65535 ,cost42218
    thread nums:8, per_thread_trx_num:65535 ,cost87016
    thread nums:16, per_thread_trx_num:65535 ,cost176943
    Performance improved by more than 60%
  2. In new write mode, new saveHistory vs old saveHistory
    set trx_time_out = 1000ms, each saveHistory will save 3000 data.
    ===========new saveHistory ====================
    thread nums:16, per_thread_trx_num:65535 ,cost 60559
    ===========old saveHistory ====================
    thread nums:16, per_thread_trx_num:65535 ,cost90189

Ⅱ. Does this pull request fix one issue?

#858

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-io
Copy link

codecov-io commented Apr 15, 2019

Codecov Report

Merging #795 into develop will decrease coverage by 0.59%.
The diff coverage is 28.57%.

Impacted file tree graph

@@             Coverage Diff              @@
##             develop     #795     +/-   ##
============================================
- Coverage      37.75%   37.16%   -0.6%     
+ Complexity      1033     1024      -9     
============================================
  Files            224      224             
  Lines           8796     8882     +86     
  Branches        1064     1065      +1     
============================================
- Hits            3321     3301     -20     
- Misses          5081     5196    +115     
+ Partials         394      385      -9
Impacted Files Coverage Δ Complexity Δ
...discovery/registery/etcd/EtcdRegistryProvider.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...covery/registery/etcd/EtcdRegistryServiceImpl.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...rc/main/java/io/seata/core/model/GlobalStatus.java 100% <ø> (ø) 7 <0> (ø) ⬇️
...in/java/io/seata/server/session/GlobalSession.java 86.11% <ø> (ø) 50 <0> (ø) ⬇️
...a/io/seata/core/rpc/netty/AbstractRpcRemoting.java 9.32% <ø> (-1.5%) 4 <0> (-1)
.../seata/server/session/FileBasedSessionManager.java 53.57% <0%> (-1.31%) 15 <0> (ø)
...in/java/io/seata/server/session/SessionHolder.java 54.79% <0%> (-4.03%) 14 <0> (ø)
...o/seata/server/coordinator/DefaultCoordinator.java 48.73% <0%> (-4.74%) 17 <0> (ø)
server/src/main/java/io/seata/server/Server.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...java/io/seata/server/session/SessionCondition.java 66.66% <100%> (+6.66%) 2 <1> (-1) ⬇️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a621865...479b230. Read the comment docs.

@zhangthen zhangthen added this to the 0.6.0 milestone Apr 16, 2019
xingfudeshi and others added 9 commits April 24, 2019 12:58
# Conflicts:
#	core/src/main/java/io/seata/core/exception/TransactionExceptionCode.java
#	server/src/main/java/io/seata/server/store/FileTransactionStoreManager.java
# Conflicts:
#	core/src/main/java/io/seata/core/exception/TransactionExceptionCode.java
#	server/src/main/java/io/seata/server/store/FileTransactionStoreManager.java
@zhangthen zhangthen removed this from the 0.6.0 milestone Apr 29, 2019
if (!writeDataFile(new TransactionWriteStore(session, logOperation).encode())) {
return false;
}
lastModifiedTime = System.currentTimeMillis();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not get file. lastModifiedTime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why use file. lastModifiedTime? I'm not sure it get the lastModifiedTime from disk every time


public void waitForFlush(long timeout) {
try {
this.countDownLatch.await(timeout, TimeUnit.MILLISECONDS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check return value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it should not check return value as rocketmq. even it happend time out , we should not block our process


private void closeAndFlush(CloseFileRequest req) {
long diff = FILE_TRX_NUM.get() - FILE_FLUSH_NUM.get();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call syncFlush()? param StoreRequest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syncFlush will weakUp. Close does not need

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@xingfudeshi xingfudeshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@CoffeeLatte007 CoffeeLatte007 merged commit da8631c into apache:develop Apr 29, 2019
nick-tan pushed a commit to nick-tan/seata that referenced this pull request Jul 12, 2019
* optimize fil write performance
@wangliang181230 wangliang181230 added this to the 0.5.* milestone Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants