Coder Social home page Coder Social logo

Comments (6)

prototypicalpro avatar prototypicalpro commented on June 5, 2024

I though the filename was extracted at compile time using the constexpr function _ShortFilePrivate::past_last_slash, I'm surprised this is not the case. My goal was for the string to be determined at compile time so that the overhead of MARK is simply copying two variables, as you mentioned.

Before we attempt to fix string parsing algorithm, I should check if it is actually possible to determine the filename entirely at compile time. If not, placing the processing in the interrupt is a good idea; In that case I would also rewrite _ShortFilePrivate::past_last_slash to use a for loop instead of recursion, which would speed it up immensely.

from featherfault.

prototypicalpro avatar prototypicalpro commented on June 5, 2024

After examining the disassembly, it seems that the __SHORT_FILE__ macro is working as intended: the filename pointer is in fact generated at compile time, and the line number and filename are copied and stored using a grand total of eight instructions (movs * 2, ldr, str).

Examining FeatherFault::_Mark, there are still several possible causes. Every time the WDT is reset, there is a synchronization period to allow the WDT clock to catch up with the system clock:

static void WDTReset() {
while(WDT->STATUS.bit.SYNCBUSY);
WDT->CLEAR.reg = WDT_CLEAR_CLEAR_KEY;
}
Since the WDT is probably clocked very slowly, this could be the issue.

Another possible hangup is the use of atomic variables in FeatherFault::_Mark:

is_being_written.store(true);
last_line = line;
last_file = file;
is_being_written.store(false);
My goal for is_being_written was to allow the fault handler to detect if the fault data has been corrupted, and viewing the disassembly it seems fairly lightweight (compiling to dmb * 2 and some load/store instructions). It does create a barrier, however, and as a result may be the cause of the problem.

from featherfault.

prototypicalpro avatar prototypicalpro commented on June 5, 2024

I found removing the atomic variable to make almost no difference in execution time, but removing the WDT reset to cut that time by a factor of ten. I will investigate if we can remove the synchronization for the WDT reset without breaking the WDT.

from featherfault.

prototypicalpro avatar prototypicalpro commented on June 5, 2024

Slow synchronization seems to be an issue with the SAMD21 processor as a whole. Since there is no way to read the WDT counter, the only way I was able to lower the WDT synchronization time was to increase the WDT clock speed, which decreased the sync delay proportionally. I was not able to remove synchronization from the WDT reset without stalling the CPU, which caused other interesting problems with the serial monitor.

from featherfault.

kamocat avatar kamocat commented on June 5, 2024

Hey, I have a crazy idea.
What if we set a global flag in MARK, and check the flag in the watchdog interrupt to decide whether to reset the MCU or to feed the watchdog? (Of course if we feed the watchdog we should clear the flag)
This effectively doubles the maximum watchdog period, and has the lowest possible overhead since the watchdog will only be fed at most once per period.

from featherfault.

prototypicalpro avatar prototypicalpro commented on June 5, 2024

Good idea! I've implemented this solution in v1.1.4, and I'm going to consider this solved.

from featherfault.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.