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

Improve the efficiency of BufferedBlockDevice #8703

Merged
merged 1 commit into from
Nov 16, 2018

Conversation

davidsaada
Copy link
Contributor

Description

Previous implementation of BufferedBlockDevice was extremely naive: It had a cache used for both writing and reading, meaning that a read action would always flush the write cache as well. In addition, write operations were split to chunks of program units, meaning that each BufferedBlockDevice program call would trigger plenty of the underlying BD's calls of this API. Reads did pretty much the same.
This change does the following:

  1. Cache is used only for write operations. Reads use a separate buffer helping against unaligned addresses/sizes (but its data doesn't live across operations).
  2. Reads and writes are only split to a minimal number of chunks according to need.

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

@davidsaada
Copy link
Contributor Author

@cmonr @0xc0170 Jenkins fails due to unavailability of the K66F board in CI (restarted a few times).

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 12, 2018

@cmonr @0xc0170 Jenkins fails due to unavailability of the K66F board in CI (restarted a few times).

👍 It was reported, and should be fixed now. We will restart failing jobs soon

@0xc0170 0xc0170 requested a review from a team November 12, 2018 08:56
Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

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

No documentation changes?

@davidsaada
Copy link
Contributor Author

No documentation changes?

No - no need to. Functionality is just the same, just more efficient.

@@ -26,7 +26,8 @@ static inline uint32_t align_down(bd_size_t val, bd_size_t size)
}

BufferedBlockDevice::BufferedBlockDevice(BlockDevice *bd)
: _bd(bd), _bd_program_size(0), _curr_aligned_addr(0), _flushed(true), _cache(0), _init_ref_count(0), _is_initialized(false)
: _bd(bd), _bd_program_size(0), _bd_read_size(0), _write_cache_addr(0), _write_cache_valid(false),
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this constructor change not need new documentation?

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't look like the constructor params changed. These are member initializers, which are internal.

Copy link
Contributor

Choose a reason for hiding this comment

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

Curse that lone :

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 13, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 13, 2018

Build : SUCCESS

Build number : 3609
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8703/

Triggering tests

/morph test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Nov 13, 2018

@mbed-ci
Copy link

mbed-ci commented Nov 13, 2018

@davidsaada
Copy link
Contributor Author

@0xc0170 @cmonr Please don't run morph test yet. Out of all unrelated failures, one (on nrf51) seems to be related to the PR.

@davidsaada
Copy link
Contributor Author

Failure in NRF51 fixed (all other failures are not related to this PR).

@NirSonnenschein
Copy link
Contributor

NirSonnenschein commented Nov 14, 2018

/morph export-build

@NirSonnenschein
Copy link
Contributor

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 14, 2018

Build : SUCCESS

Build number : 3618
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8703/

Triggering tests

/morph test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Nov 14, 2018

@mbed-ci
Copy link

mbed-ci commented Nov 14, 2018

@mbed-ci
Copy link

mbed-ci commented Nov 14, 2018

@cmonr
Copy link
Contributor

cmonr commented Nov 14, 2018

Test failures appear to be a whole bunch of sporadic netsocket echo issues, unrelated to CI.

Will restart when able.

Copy link
Contributor

@geky geky left a comment

Choose a reason for hiding this comment

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

This looks great 👍

@@ -110,36 +124,52 @@ int BufferedBlockDevice::sync()

int BufferedBlockDevice::read(void *b, bd_addr_t addr, bd_size_t size)
{
MBED_ASSERT(_cache);
MBED_ASSERT(_write_cache);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be?

Suggested change
MBED_ASSERT(_write_cache);
MBED_ASSERT(_read_cache);

Also should there be a similar assert in BlockDevice::program?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@cmonr, given the dependencies, it's probably better to just move forward with testing. The assert is minor and can be fixed after the release (or if @davidsaada has to make further changes).

Copy link
Contributor

Choose a reason for hiding this comment

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

@geky Alright, that sounds reasonable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used those damned netsocket test failures to fix these asserts.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 15, 2018

/morph test

@cmonr
Copy link
Contributor

cmonr commented Nov 15, 2018

@davidsaada Was this PR just rebased?

@davidsaada
Copy link
Contributor Author

Was this PR just rebased?

Rebased it as part of the fixes (assert fixes).

@cmonr
Copy link
Contributor

cmonr commented Nov 15, 2018

Info: This PR has now been bundled into a rollup PR (#8760).

The CI failures that this PR saw do not appear to be the fault of the PR. To save time in retesting this PR, along with other PRs that experienced similar issues, it has been bundled into a rollup PR.

If any more commits are made in this PR, this PR will remain open and have to go through CI on its own.

@cmonr
Copy link
Contributor

cmonr commented Nov 16, 2018

Info: This PR has been re-bundled into a new rollup PR (#8763).

The previous rollup found an issue with a bundled PR after new devices were added into master. The PR needing work has been removed.

No further work is needed here, as once that PR is merged, this PR will also be closed and marked as merged.
If any more commits are made in this PR, this PR will remain open and have to go through CI on its own.

@0xc0170 0xc0170 merged commit 50836e7 into ARMmbed:master Nov 16, 2018
@0xc0170 0xc0170 removed the needs: CI label Nov 16, 2018
@davidsaada davidsaada deleted the david_buffered_bd_perf branch December 6, 2018 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants